package com.woniuxy.woniuticket.movieinfomodule.controller;

import com.woniuxy.woniuticket.movieinfomodule.dto.UserandVip;
import com.woniuxy.woniuticket.movieinfomodule.service.impl.CinemaVipServiceImp;
import com.woniuxy.woniuticket.pojo.CinemaVip;
import com.woniuxy.woniuticket.utils.PageUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ZYF
 * @Description:TODO
 * @date 2019/6/13
 * @Version 1.0
 */
@Controller
public class CinemaVipController {
    @Resource
    private CinemaVipServiceImp cinemaVipServiceImp;

    //展示所有Vip
    @RequestMapping("/cinemaVip/allVip")
    @ResponseBody
    public Map showVip(@RequestParam("page") int  page, @RequestParam("limit") int limit){
        System.out.println("aaaa");
        List<CinemaVip> list = cinemaVipServiceImp.showAllVip();
        //System.out.println(list);
        Map map = PageUtil.page(list,limit,page);
        return map;
    }

    //删除选中VIP信息
    @RequestMapping("/cinemaVip/deleteVip")
    @ResponseBody
    public String deleteVip(Integer id){
        String message = cinemaVipServiceImp.deleVip(id);
        return message;
    }
    //修改VIP
    @RequestMapping("/cinemaVip/updateVip")
    @ResponseBody
    public String updateVip(CinemaVip vip){
        cinemaVipServiceImp.updateVip(vip);
        return "success";
    }

    //添加VIP
    @RequestMapping("/cinemaVip/addVip")
    @ResponseBody
    public String addVip(CinemaVip vip){
        cinemaVipServiceImp.addVip(vip);
        return "success";
    }

}
